import { queryAttendanceHistory } from '@/services/api';

export default {
  namespace: 'attendance',
  state: {
    attendanceHistory: {
      list: [],
      pagination: {},
    },
  },

  effects: {
    *fetch({ payload, callback }, { call, put }) {
      const response = yield call(queryAttendanceHistory, payload);
      yield put({
        type: 'query',
        payload: response,
      });

      if (callback) callback();
    },
    // *fetch()
  },

  reducers: {
    query(state, { payload }) {
      return {
        ...state,
        attendanceHistory: payload,
      };
    },
    clear(state) {
      return {
        ...state,
        attendanceHistory: [],
      };
    },
  },
};
